package com.bdqn.t296.noso;

import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.Jedis;

public class JedisTester {
    private Jedis jedis;

    @Before
    public void setup() {
        //连接 redis 服务器，127.0.0.1:6379
        jedis = new Jedis("127.0.0.1", 6379);
    }

    @Test
    public void testString() {
        //-----添加数据----------
        jedis.set("name", "ktjiaoyu");//向 key-->name 中放入了 value-->ktjiaoyu
        System.out.println(jedis.get("name"));//执行结果：ktjiaoyu

        jedis.append("name", "czkt"); //拼接
        System.out.println(jedis.get("name"));

        jedis.del("name"); //删除某个键
        System.out.println(jedis.get("name"));
        /*
        //设置多个键值对
        jedis.mset("name", "ktjiaoyu", "age", "17", "add", "cz");
        jedis.incr("age"); //进行加 1 操作
        System.out.println(jedis.get("name") + "-" + jedis.get("age") + "-" + jedis
                .get("add"));*/
    }
}
